Hi Statalista, please, could anyone help me with my loop code?
I have 10 .dta. Each one is called file1, file2...file10.
I need to run commands creating new variables in each of those files.
I am trying to do the following but it is not working.
Thank you!!
I have 10 .dta. Each one is called file1, file2...file10.
I need to run commands creating new variables in each of those files.
I am trying to do the following but it is not working.
Thank you!!
Code:
local list 1 2 3 4 5 6 7 8 9 10 foreach value of local list{ use file`var' , clear foreach i in x1 x2 x3 { gen sum_`i' = 'i`/weight gen partial_`i' = 1/weight gen total_`'i = sum_`i'/partial_`i' save new file_`var' } }
Comment